<?php
//session_start();
//include_once("conn.php");
//include_once("sidebar.php");
?>
<html>
<head>
<link rel = "stylesheet" href = "sidebar.css" style = 'text/css' />
<link rel = "stylesheet" href = "top_ten.css" style = "text/css" />
<meta http-equiv="Content-Type" content="text/html" charset="utf-8" />
</head>
<body>
<?php
include_once("conn.php");
include_once("sidebar.php");

?>
<div class = "header">
<p><img src = "photos/top10.gif" /></p>
</div>
<hr>

<div class = "body">
<table class = "tb_top_ten">
<tr>
	<th>名次</th>
	<th>讨论区</th>
	<th>标题</th>
	<th>作者</th>
	<th id = "th_huifu">回复量</th>
</tr>


		<?php	$level = 1;
				include_once("conn.php");
				$sql = "select count(r_id) as huifu_count,r_t_name,r_tid from bbs_reply group by r_tid order by huifu_count desc limit 10";
				$result = mysql_query($sql);
				while($q_result = mysql_fetch_array($result))
				{
					$sd_t_name = $q_result["r_t_name"];		//十大贴的贴名
					$sd_tid = $q_result["r_tid"];				//十大贴的ID
					$sql2 = "select * from bbs_topic where t_id = '".$sd_tid."'";
					$result2 = mysql_query($sql2);
					$q_result2 = mysql_fetch_array($result2);
					$sd_board = $q_result2["t_session_name"];			//十大贴所在的版块
					$sd_author = $q_result2["t_author"];				//十大贴的作者
				
					$sql2 = "select count(r_id) as reply_num from bbs_reply where r_tid = '".$sd_tid."'";
					$result2 = mysql_query($sql2);
					$q_result2 = mysql_fetch_array($result2);
					$reply_num = $q_result2["reply_num"];		//本贴的回贴数量
			?>
					<tr>
						<td><?php echo $level;$level=$level+1; ?></td>
						<td class = "td_board"><a href = "page.php?board=<?php echo $sd_board; ?>"><?php echo $sd_board; ?></a></td>
						<td class = "td_bt"><a href = "browse.php?board=<?php echo $sd_board;   ?>&tid=<?php echo $sd_tid; ?>"><?php echo $sd_t_name; ?></a></td>
						<td><?php echo $sd_author; ?></td>
						<td class = "td_huifu"><?php echo $reply_num; ?></td>
					
					<tr>
		<?php
				}

		?>



</table>
</div>

</body>
</html>